package com.journaldev.spring.model;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name="thuoc")
public class Medicine {

	
	
	public Medicine(int id, String medicineName, String manufactureName,
			Long priceValue, Integer numOfMedicine,
			UserInfo drugsBelongToDoctor,
			Set<PrescriptionMedicine> prescMedicine) {
		super();
		this.id = id;
		this.medicineName = medicineName;
		this.manufactureName = manufactureName;
		this.priceValue = priceValue;
		this.numOfMedicine = numOfMedicine;
		this.drugsBelongToDoctor = drugsBelongToDoctor;
		this.prescriptionMedicine = prescMedicine;
	}

	public Medicine() {
		// TODO Auto-generated constructor stub
	}

	@Id
	@Column(name="id_thuoc")
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private int id;
	
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getMedicineName() {
		return medicineName;
	}

	public void setMedicineName(String medicineName) {
		this.medicineName = medicineName;
	}

	public String getManufactureName() {
		return manufactureName;
	}

	public void setManufactureName(String manufactureName) {
		this.manufactureName = manufactureName;
	}

	public Long getPriceValue() {
		return priceValue;
	}

	public void setPriceValue(Long priceValue) {
		this.priceValue = priceValue;
	}

	@Column(name="tenthuoc")
	private String medicineName;
	
	@Column(name="hangsanxuat")
	private String manufactureName;
	
	@Column(name="dongia")
	private Long priceValue;
	
	@Column(name="soluong")
	private Integer numOfMedicine;

	public Integer getNumOfMedicine() {
		return numOfMedicine;
	}

	public void setNumOfMedicine(Integer numOfMedicine) {
		this.numOfMedicine = numOfMedicine;
	}
	
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "id_user")
	private UserInfo drugsBelongToDoctor;

	public UserInfo getDrugsBelongToDoctor() {
		return drugsBelongToDoctor;
	}

	public void setDrugsBelongToDoctor(UserInfo drugsBelongToDoctor) {
		this.drugsBelongToDoctor = drugsBelongToDoctor;
	}
	
	@OneToMany(fetch = FetchType.LAZY, mappedBy = "pk.medicine")
	private Set<PrescriptionMedicine> prescriptionMedicine = new HashSet<PrescriptionMedicine>(0);
	
	public Set<PrescriptionMedicine> getPrescMedicine() {
		return this.prescriptionMedicine;
	}
 
	public void setPrescMedicine(Set<PrescriptionMedicine> presMed) {
		this.prescriptionMedicine = presMed;
	}

}
